<?php namespace App\Models\Filters;

use EloquentFilter\ModelFilter;

class SiteFilter extends ModelFilter
{
    /**
    * Related Models that have ModelFilters as well as the method on the ModelFilter
    * As [relationMethod => [input_key1, input_key2]].
    *
    * @var array
    */
    public $relations = [];

    public function title($value)
    {
        return $this->whereLike('title', $value);
    }
    public function username($name)
    {
        return $this->whereHas('user', function($query) use ($name) {
            return $query->where('name', 'LIKE', '%' . $name . '%');
        });
    }
}
